<template>
  <transition name="el-zoom-in-center">
    <div class="JADP-preview-main">
      <div class="JADP-common-page-header">
        <el-page-header @back="goBack" content="学员评价"> </el-page-header>
        <div class="options">
          <el-button @click="goBack">取 消</el-button>
        </div>
      </div>
      <div class="JADP-common-layout">
        <div class="JADP-common-layout-center">
          <el-row class="JADP-common-search-box" :gutter="16">
            <el-form @submit.native.prevent>
              <el-col :span="6">
                <el-form-item label="学员姓名">
                  <el-input
                    v-model="query.studentname"
                    placeholder="请输入学员姓名"
                    clearable
                  >
                  </el-input>
                </el-form-item>
              </el-col>

              <el-col :span="6">
                <el-form-item>
                  <el-button
                    type="primary"
                    icon="el-icon-search"
                    @click="search"
                    >查询</el-button
                  >
                  <el-button icon="el-icon-refresh-right" @click="reset"
                    >重置</el-button
                  >
                </el-form-item>
              </el-col>
            </el-form>
          </el-row>
          <div class="JADP-common-layout-main JADP-flex-main">
            <el-tabs v-model="activeName" @tab-click="handleClick">
              <el-tab-pane label="班级评价" name="first">
                <List ref="List1" :classid="classid" :categoretype="1" />
              </el-tab-pane>
              <el-tab-pane label="课件评价" name="second">
                <List ref="List2" :classid="classid" :categoretype="3" />
              </el-tab-pane>
              <el-tab-pane label="讲师评价" name="third">
                <List ref="List3" :classid="classid" :categoretype="4" />
              </el-tab-pane>
            </el-tabs>
          </div>
        </div>
      </div>
    </div>
  </transition>
</template>
<script>
import List from "./List.vue";
export default {
  name: "evaluation",
  components: {
    List
  },
  props: {
    categore: {
      type: String,
      default: ""
    },
    categoretype: {
      type: [String, Number],
      default: ""
    }
  },
  data() {
    return {
      query: {
        studentname: undefined
      },
      listLoading: false,
      classList: [],
      coursewareList: [],
      lecturerList: [],
      evaluationList: [],
      formVisible: false,
      compositeScore: 0,
      evaluationListSvg: [],
      classid: "",
      activeName: "first"
    };
  },
  mounted() {
    setTimeout(() => {
      this.$refs.List1.initData();
    });
  },
  methods: {
    goBack() {
      this.$emit("refresh", true);
    },
    handleClick(tab, event) {
      if (tab.name == "first") {
        this.$refs.List1.initData();
      } else if (tab.name == "second") {
        this.$refs.List2.initData();
      } else if (tab.name == "third") {
        this.$refs.List3.initData();
      }
    },
    // async initData() {
    //   this.listLoading = true;
    //   let query = {
    //     ...this.listQuery,
    //     ...this.query,
    //     classid: this.classid,
    //     categoretype: 1, // 1-培训班  2-课程 3-课件  4-讲师
    //   };
    //   const { data } = await getEvaluationList(query);
    //   this.classList = data.list;
    //   console.log(data, 132);
    //   this.total = data.pagination.total;
    //   this.listLoading = false;
    // },
    // view(id) {
    //   this.formVisible = true;
    //   this.$nextTick(() => {
    //     this.$refs.Form.initData(id);
    //   });
    // },
    // async getEvaluationAvg() {
    //   await getEvaluationAvg({
    //     coursemanageid: this.coursemanageid,
    //     categoreid: this.categore,
    //     manageid: this.manageid,
    //     categoretype: this.categoretype,
    //   }).then((res) => {
    //     console.log(res, 123);
    //     this.compositeScore = res.msg;
    //   });
    // },
    // async getEvaluationCatalog() {
    //   await getEvaluationCatalog({
    //     coursemanageid: this.coursemanageid,
    //     categoreid: this.categore,
    //     manageid: this.manageid,
    //     categoretype: this.categoretype,
    //   }).then((res) => {
    //     console.log(res, 456);
    //     this.evaluationList = res.data;
    //     this.evaluationList.forEach((item) => {
    //       item.grade = item.grade / (item.score / 5);
    //     });
    //   });
    // },
    search() {
      if (this.activeName == "first") {
        this.$refs.List1.query.studentname = this.query.studentname;
        this.$refs.List1.initData();
      } else if (this.activeName == "second") {
        this.$refs.List2.query.studentname = this.query.studentname;
        this.$refs.List2.initData();
      } else if (this.activeName == "third") {
        this.$refs.List3.query.studentname = this.query.studentname;
        this.$refs.List3.initData();
      }
    },
    reset() {
      this.query.studentname = undefined;
      this.search();
    }
  }
};
</script>
<style scoped lang="scss">
.statistics {
  padding: 16px;
  display: flex;
  .statistics_left {
    position: relative;
    width: 50%;
    height: 300px;
    border: 1px solid #ebeef5;
    text-align: center;
    .CompositeScore {
      position: absolute;
      top: 50%;
      left: 50%;
      transform: translate(-50%, -80%);
      font-size: 40px;
      & > span:first-child {
        font-size: 45px;
        color: #6c94e8;
      }
      & > span:last-child {
        font-size: 20px;
        color: #87bff1;
      }
    }
  }
  .statistics_right {
    width: 50%;
    height: 300px;
    border: 1px solid #ebeef5;
    margin-left: 20px;
  }
}
.rate_text {
  display: inline-block;
  color: #f7ba2a;
  transform: translate(10px, 2px);
}

::v-deep .el-tabs__nav {
  transform: translateX(20px) !important;
}
</style>
